package by.dezhits.liltweets.auth;


import android.os.AsyncTask;

public class TwitterRecieveRequestTokenTask extends AsyncTask<TwitterCallback<String>,String,Object>{
	private TwitterCallback<String> callback;
	
	@Override
	protected Object doInBackground(TwitterCallback<String>... callback){
		this.callback = callback[0];
		try{
			return TwitterAuthHelper.getProvider().retrieveRequestToken(TwitterAuthHelper.getConsumer(), TwitterAuthHelper.CALLBACK_URL);
		}
		catch(Exception e){
			return e;
		}
	}
	
	@Override
	protected void onPostExecute(Object result){
		if (result instanceof String){
			this.callback.onSuccess((String)result);
		}
		else{
			this.callback.onError();
		}
	}
}
